/*
 * Copyright © 2004-2014 chenYuan. All rights reserved.
 * @Website:wwww.jspx.net
 * @Mail:39793751@qq.com
 * @author: chenYuan , 陈原
 * @License: Jspx.net Framework Code is open source (LGPL)，Jspx.net Framework 使用LGPL 开源授权协议发布。
 * @jvm:jdk1.6+  x86/amd64
 *
 */
package com.jspx.txweb.view;

import com.jspx.txweb.annotation.HttpMethod;
import com.jspx.txweb.annotation.Safety;
import com.jspx.txweb.dispatcher.Dispatcher;
import com.jspx.txweb.support.ActionSupport;
import com.jspx.utils.StringUtil;

import java.io.Writer;

/**
 * Created by IntelliJ IDEA.
 * User: Administrator
 * Date: 12-3-3
 * Time: 下午11:36
 * 提供服务器验证方式
 */
@HttpMethod(caption="服务器函数")
public abstract class WebMethodView extends ActionSupport {


    protected String formId = null;

    protected String value = null;
    @Safety(length = 400)
    public void setValue(String value) {
        this.value = value;
    }
    @Safety(length =100)
    public void setFormId(String formId) {
       this.formId = formId;
    }

    @Override
    public String execute() throws Exception {

        response.setHeader("Pragma", "No-cache");
        response.setHeader("Cache-Control", "no-cache,must-revalidate");
        response.setDateHeader("Expires", 0);
        response.setContentType("text/html; charset=" + Dispatcher.getEncode());
        Writer out = response.getWriter();
        if (!StringUtil.isNULL((String) getResult())) {
            out.write((String) getResult());
        }
        out.flush();
        out.close();
        return NONE;
    }
}